package net.zhengxinyun.performance.App.appCtrl;

import net.zhengxinyun.performance.App.entity.EcoIndexentity;
import net.zhengxinyun.performance.App.entity.PishiEntity;
import net.zhengxinyun.performance.App.entity.ZhongDianWorkEntity;
import net.zhengxinyun.performance.App.service.DuCha.DuchaService;
import net.zhengxinyun.performance.core.Result;
import net.zhengxinyun.performance.core.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ling
 * Date: 2019/12/11
 * Time: 12:32
 * To change this template use File | Settings | File Templates.
 * Description: 领导绩效分数
 */
@RestController
@RequestMapping("/app/leaderScore")
public class LeaderScoreCtrl extends BaseCtrl {
    @Autowired
    private DuchaService duchaService;

    /**
     * 重点工作
     * @param entity
     * @return
     */
    @PostMapping(value = "/zhongdianList")
    public Result<HashMap<String, Object>> zhongdianList(@RequestBody ZhongDianWorkEntity entity){
        List<ZhongDianWorkEntity> querywork = duchaService.querywork(entity);
        HashMap<String, Object> map = new HashMap<>();
        map.put("data", querywork);
        return ResultUtils.getResults(Result.Status.SUCCESS, "重点工作列表", map);
    }
    /**
     * 新增重点
     * @param entity
     * @return
     */
    @PostMapping(value = "/insertZhongdian")
    public Result<String>insertZhongdian(@RequestBody ZhongDianWorkEntity entity){
        int i = duchaService.insertzhongdian(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "新增失败" );
        }
    }

    /**
     * 修改重点
     * @param entity
     * @return
     */
    @PostMapping(value = "/updateZhongdian")
    public Result<String>updateZhongdian(@RequestBody ZhongDianWorkEntity entity){
        int i = duchaService.updatezhongdian(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "修改失败" );
        }
    }

    /**
     * 删除重点
     * @param entity
     * @return
     */
    @PostMapping(value = "/deleteZhongdian")
    public Result<String>deleteZhongdian(@RequestBody ZhongDianWorkEntity entity){
        int i = duchaService.deletezhongdian(entity.getId());
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "删除失败");
        }
    }

    /* =================================批示==============================================*/
    /**
     * 批示件
     * @param entity
     * @return
     */
    @PostMapping(value = "/queryPishi")
    public Result<HashMap<String, Object>> queryPishi(@RequestBody PishiEntity entity){
        List<PishiEntity> list = duchaService.querypishi(entity);
        HashMap<String, Object> map = new HashMap<>();
        map.put("data", list);
        return ResultUtils.getResults(Result.Status.SUCCESS, "批示件列表", map);
    }
    /**
     * 新增
     * @param entity
     * @return
     */
    @PostMapping(value = "/insertPishi")
    public Result<String>insertPishi(@RequestBody PishiEntity entity){
        int i = duchaService.insertpishi(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "新增失败" );
        }
    }

    /**
     * 修改
     * @param entity
     * @return
     */
    @PostMapping(value = "/updatePishi")
    public Result<String>updatePishi(@RequestBody PishiEntity entity){
        int i = duchaService.updatepishi(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "修改失败" );
        }
    }

    /**
     * 删除
     * @param entity
     * @return
     */
    @PostMapping(value = "/deletePishi")
    public Result<String>deletePishi(@RequestBody PishiEntity entity){
        int i = duchaService.deletepishi(entity.getId());
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "删除失败");
        }
    }

    /* =================================指标==============================================*/
    /**
     * 指标
     * @param entity
     * @return
     */
    @PostMapping(value = "/queryEcoIndex")
    public Result<HashMap<String, Object>> queryEcoIndex(@RequestBody EcoIndexentity entity){
        List<EcoIndexentity> list = duchaService.queryEcoIndex(entity);
        HashMap<String, Object> map = new HashMap<>();
        map.put("data", list);
        return ResultUtils.getResults(Result.Status.SUCCESS, "批示件列表", map);
    }
    /**
     * 新增
     * @param entity
     * @return
     */
    @PostMapping(value = "/insertEcoIndex")
    public Result<String>insertEcoIndex(@RequestBody EcoIndexentity entity){
        int i = duchaService.insertEcoIndex(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "新增失败" );
        }
    }

    /**
     * 修改
     * @param entity
     * @return
     */
    @PostMapping(value = "/updateEcoIndex")
    public Result<String>updateEcoIndex(@RequestBody EcoIndexentity entity){
        int i = duchaService.updateEcoIndex(entity);
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "修改失败" );
        }
    }

    /**
     * 删除
     * @param entity
     * @return
     */
    @PostMapping(value = "/deleteEcoIndex")
    public Result<String>deleteEcoIndex(@RequestBody EcoIndexentity entity){
        int i = duchaService.deleteEcoIndex(entity.getId());
        if (1==i){
            return ResultUtils.getSuccessResults();
        }else{
            return ResultUtils.getResults(Result.Status.ERROR, "删除失败");
        }
    }

}
